Repository navigation
perf(diff): parallel copy, hashing and cleanup, and --format json - #2021
Open
italo-kalil-cesar wants to merge 2 commits into
Open
italo-kalil-cesar wants to merge 2 commits into
italo-kalil-cesar wants to merge 2 commits into
Conversation
mxcli diff spent most of its time (about 18 s of 26 s on a 3,100-unit project, Windows) copying the project one file at a time, then hashing the files next to the model and removing the scratch folder one file at a time. - copyProject: regular files are copied by a pool of workers (directories and symlinks are still created in walk order). - TakeSnapshot: the files next to the model are hashed by a pool of workers. - Scratch.Close: the first three levels of the scratch folder are removed in parallel. - packages/ (deployment packages exported by Studio Pro) joins the skipped directories: build output that exec never reads or writes. - MXCLI_DIFF_TIMING=1 prints the time of each stage of a diff to stderr. Measured on one project (3,138 units, ~430 MB outside the skipped directories): diff of a one-statement script 30.8 s -> about 13 s; same output as before on the scripts tried. Tests: the copy skips the build directories and copies every file, the parallel removal removes the tree, the file hash is SHA-256. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
For a tool that has to decide on the result of a diff without parsing the text: refused, preflight, execError, failures, units, documents, files and summary. A script exec would refuse reports refused and summary.writesNothing. Docs: the diff page gains a JSON output section, the flag help and the --json refusal hint name the format, and CHANGELOG has the entry. Tests: a modified document and file are reported with the right kinds and summary; a refused script has writesNothing and empty (not null) lists. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #2014
Marked ready for review. The issue asks the maintainers whether a faster
diffis in scope and which JSON spelling they prefer.What was wrong
mxcli diffspent most of its time copying the project to the scratch folder one file at a time, hashing the files next to the model one at a time, and removing the scratch folder one file at a time (about 18 s of 26 s on a project of about 3 thousand units, Windows). A tool also had to parse the text of the diff to know the result.What changes
Two commits, one thing each:
scriptdiff: parallel copy, hashing and cleanup; skip packages/; timing: regular files are copied by a pool of workers, the files next to the model are hashed by a pool, the first three levels of the scratch folder are removed in parallel.packages/(deployment packages exported by Studio Pro, never read or written by exec) joins the directories the copy leaves out.MXCLI_DIFF_TIMING=1prints each stage's time to stderr. Docs: diff page and command help; CHANGELOG.diff: --format json prints the report as one JSON document:refused,preflight,execError,failures,units,documents,files,summary. Docs: JSON output section, flag help, the--jsonrefusal hint; CHANGELOG.Question for the maintainers: other commands expose JSON through the global
--jsonflag (diffrefused it so far, with a hint). This adds--format jsoninstead, aslintandreportdo. If you prefer--json, the report writer is the same and only the flag wiring changes.Measured
Project of about 3 thousand units (about 430 MB outside the skipped directories), Windows: a one-statement script 30.8 s -> about 13 s, same report on the scripts tried. That is the sum of the three parallel changes and the skipped directory; they were not measured one by one.
Tests
parallel_test.go(copy skips the build directories and copies every file; parallel removal; SHA-256 file hash) andjson_test.go(modified document and file; refused script reportswritesNothingand empty lists). Smoke test ofmxcli diff --format jsonon the PedApp fixture: an added enumeration is reported as expected, and a refused script prints the refusal withwritesNothing: true.go test ./mdl/scriptdiff: ok exceptTestDiffFollowsAConnectToTheProjectOntoTheCopy, which fails on Windows at TempDir cleanup (open file) and fails the same on main.Run locally
Run on Windows without make; the equivalents were run by hand:
go build ./...: cleango veton the touched packages: cleangofmt -lon the touched files: emptygo test -timeout ...on the touched packages: see Testsmake check-test-timeouts,make check-findings: not run (bash and make are not available here); no Makefile or findings file is touchedStudio Pro validation
Not run. diff writes nothing to the project.
Agentic testing
Not run.